home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / StepAndRepeatDeLuxe.pprx < prev    next >
Text File  |  1993-08-07  |  13KB  |  367 lines

  1. /*
  2. StepAndRepeatDeLuxe  
  3. This Genie will make multiple copies of a box with user specified offset and rotation between copies. You can also scale the copies and set the centre of rotation. 
  4. Written by Don Cox   July 92., debug Aug 93. Not Public Domain. All rights reserved. 
  5. */
  6.  
  7.  
  8. if ~show("l", "gdarexxsupport.library") then
  9.     if ~addlib("gdarexxsupport.library", 0, -30,0) then
  10.     do
  11.         call ppm_Inform(1,"Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  12.     end
  13.  
  14.  
  15. cr = '0a'x
  16. address command
  17. call SafeEndEdit.rexx()
  18. units = ppm_GetUnits()
  19. if units = 3 then call ppm_SetUnits(2)
  20.  
  21. signal on halt
  22. signal on break_c
  23. signal on break_e
  24. signal on break_d
  25.  
  26. cu = "in"
  27. if units = 2 then cu = "cm"
  28.  
  29. call ppm_AutoUpdate(0)
  30.  
  31. call ppm_NewGroup()
  32. box = ppm_ClickOnBox("Click on box to duplicate..")
  33. if box = 0 then exit_msg("No box selected")
  34. call ppm_AddToGroup(box)  /* whole set grouped including original box */
  35. dup = 0
  36.  
  37. trace n
  38.  
  39. source = ppm_Inform(3,"Settings from...","Same again","Defaults","Disk file")
  40.  
  41. oldangle = ppm_GetBoxAngle(box)
  42. call ppm_SetBoxAngle(box,0)   /* rotate to zero to get centre */
  43. boxpos  = ppm_GetBoxPosition(box)
  44. curX   = word(boxpos, 1 )
  45. curY   = word(boxpos, 2 )
  46.  
  47. boxsize = ppm_GetBoxSize(box)
  48. width   = word(boxsize, 1 )
  49. height  = word(boxsize, 2 )
  50.  
  51. centreX = curX+(width/2)
  52. centreY = curY+(height/2)
  53. call ppm_SetBoxAngle(box,oldangle)
  54. boxpos  = ppm_GetBoxPosition(box)
  55.  
  56. ImageScaleX = word(ppm_GetBoxScale(box),1)
  57. ImageScaleY = word(ppm_GetBoxScale(box),2)
  58.  
  59. call ppm_ShowStatus("Position: "curX", "curY" size: w"width", h"height)
  60.  
  61. formstring = ""
  62.  
  63. if source = 0 then do
  64.     if open("temp","ram:SRD.data","R") then do
  65.         formstring = readch("temp",512)
  66.         call close("temp")
  67.         end
  68.     if formstring = "" then source = 1  /* defaults if failed  */
  69.     end   /* source = 0  */
  70.  
  71. if source = 2 then do
  72.     loadfile = ppm_GetFileName("Load settings from disk","PPage:","")
  73.     if loadfile = "" then break
  74.     if open("loader",loadfile,"R") then do
  75.         formstring = readch("loader",512)
  76.         call close("loader")
  77.         end
  78.     if formstring = "" then source = 1  /* go for defaults  */
  79.     end
  80.  
  81. if formstring = "" then formstring ="rows:2"||cr"columns:1"||cr"horiz. spacing ("cu"):"width||cr"vertical spacing ("cu"):"height||cr"horiz. offset ("cu"):"0||cr"offset angle:"0||cr"rotation angle:"0||cr"rotation centre, X:"centreX||cr"rotation centre, Y:"centreY||cr"scale, X:1.00"||cr"scale, Y:1.00"||cr"spiral scale:1.00"||cr"spiral spacing("cu"):0"||cr"save settings (Y/N):N"||cr"Link boxes (Y/N):N"
  82.  
  83.  
  84. form = ppm_GetForm("Step & Repeat DeLuxe", 12, formstring)
  85. if form = '' then exit_msg("Aborted by User")
  86.  
  87. parse var form rows '0a'x columns '0a'x  horizontal '0a'x vertical '0a'x HorizOffset '0a'x OffsetAngle '0a'x RotAngle '0a'x Xcentre '0a'x Ycentre '0a'x Xscale '0a'x Yscale '0a'x SpiralScale '0a'x SpiralIncrement '0a'x Saving '0a'x Linking
  88.  
  89.  
  90. if rows = '' then rows = 1
  91. if columns = '' then columns = 1
  92. if horizontal = '' then horizontal = 0
  93. if vertical = '' then vertical = 0
  94. if HorizOffset = "" then HorizOffset = 0
  95. if OffsetAngle = "" then OffsetAngle = 0
  96. if RotAngle = '' then RotAngle = 0
  97. if Xcentre = "" then Xcentre = centreX
  98. if Ycentre = "" then Ycentre = centreY
  99. if Xscale = "" then Xscale = 1
  100. if Yscale = "" then Yscale = 1
  101. if SpiralScale = "" then SpiralScale = 1
  102. if SpiralIncrement = "" then SpiralIncrement = 0
  103.  
  104. if ~(datatype(rows, n)) then exit_msg("Invalid Entry for Rows: "rows)
  105. if ~(datatype(columns, n)) then exit_msg("Invalid Entry for Columns: "columns)
  106. if ~(datatype(horizontal, n)) then exit_msg("Invalid Entry for Horiz. Spacing: "horizontal)
  107. if ~(datatype(HorizOffset, n)) then exit_msg("Invalid Entry for Horiz. Offset: "HorizOffset)
  108. if ~(datatype(vertical, n)) then exit_msg("Invalid Entry for Vertical Spacing: "vertical)
  109. if ~(datatype(OffsetAngle, n)) then exit_msg("Invalid Entry for Offset Angle: "OffsetAngle)
  110. if ~(datatype(RotAngle, n)) then exit_msg("Invalid Entry for Rotation Angle: "RotAngle)
  111. if ~(datatype(Xcentre, n)) then exit_msg("Invalid Entry for Rotation Centre X: "Xcentre)
  112. if ~(datatype(Ycentre, n)) then exit_msg("Invalid Entry for Rotation Centre Y: "Ycentre)
  113. if ~(datatype(Xscale, n)) then exit_msg("Invalid Entry for X scale: "Xscale)
  114. if ~(datatype(Yscale, n)) then exit_msg("Invalid Entry for Y scale: "Yscale)
  115. if ~(datatype(SpiralScale, n)) then exit_msg("Invalid Entry for Spiral Scale: "SpiralScale)
  116. if ~(datatype(SpiralIncrement, n)) then exit_msg("Invalid Entry for Spiral Increment: "SpiralIncrement)
  117.  
  118. formstring ="rows:"rows||"0a"x"columns:"columns||"0a"x"horiz. spacing ("cu"):"horizontal||"0a"x"vertical spacing ("cu"):"vertical||"0a"x"horiz. offset ("cu"):"HorizOffset||"0a"x"offset angle:"OffsetAngle||"0a"x"rotation angle:"RotAngle||"0a"x"rotation centre, X:"Xcentre||"0a"x"rotation centre, Y:"Ycentre||"0a"x"scale, X:"Xscale||"0a"x"scale, Y:"Yscale||"0a"x"spiral scale:"SpiralScale||"0a"x"spiral spacing("cu"):"SpiralIncrement||"0a"x"save settings (Y/N):"upper(Saving)||"0a"x"Link boxes (Y/N):"upper(Linking)"0a"x
  119.  
  120. if open("temp","ram:SRD.data","W") then do
  121.     call seek("temp",0,"B") 
  122.     call writech("temp",formstring)
  123.     call close("temp")
  124.     end
  125.  
  126. if upper(Saving) = "Y" then do
  127.     savefile = ppm_GetFileName("Save settings to disk","PPage:","")
  128.     if savefile = "" then break
  129.     if open("saver",savefile,"W") then do
  130.         call writech("saver",formstring)
  131.         call close("saver")
  132.         end
  133.     end
  134.  
  135. if RotAngle ~=0 then SpiralIncrement = SpiralIncrement/(360/RotAngle) /* get value for each unit  */
  136.  
  137. if upper(linking)="Y" then do /* don't try to link if not text */
  138.     info = ppm_GetBoxInfo(box)
  139.     boxtype = word(info,1)
  140.     if upper(boxtype) ~= "TEXT" then linking = "N"
  141.     end
  142.  
  143. AroundCentre = 0
  144. if centreX ~= Xcentre | centreY ~= Ycentre then AroundCentre = 1
  145. rotationangle = oldangle
  146. HorizShift = 0   /* sideways shift for offset angle */
  147. if OffsetAngle ~= 0 then do  /* use horiz. spacing and offset angle */
  148.     Oangle=OffsetAngle*3.1415926/180  /* convert to radians  */
  149.     vertical = horizontal*sin(Oangle)
  150.     HorizShift = horizontal*cos(Oangle)
  151.     end
  152. ScaledWidth = width
  153. ScaledHeight = height
  154. ScaledImageX = ImageScaleX
  155. ScaledImageY = ImageScaleY
  156. scaling = 0
  157. if Xscale~=1 | Yscale~=1 then scaling = 1    /* set scaling flag  */
  158.  
  159. boxes.1.1 = box
  160.  
  161.  
  162. /* For single rows or lines of units */
  163. if rows = 1 | columns = 1 then do
  164.     call ppm_ShowStatus("   Working on single column ")
  165.     do i = 2 to max(rows,columns)
  166.         k=i-1
  167.         box = boxes.1.k
  168.         
  169.         /* to avoid a bug in CloneBox we have to clone first and then set the position  */
  170.         boxX=word(ppm_GetBoxPosition(box),1)
  171.         boxY=word(ppm_GetBoxPosition(box),2)
  172.         boxX=boxX+HorizShift+HorizOffset+horizontal
  173.         boxY=boxY+vertical
  174.         newbox = ppm_CloneBox(box, 0,0)
  175.         call ppm_AddToGroup(newbox)
  176.         call ppm_SetBoxPosition(newbox,boxX,boxY)
  177.         
  178.         boxes.1.i = newbox
  179.         if rotangle ~= 0 then do
  180.             newangle = (rotationangle + rotangle)//360
  181.             call ppm_SetBoxAngle(newbox, newangle)
  182.             rotationangle = newangle
  183.             end
  184.  
  185.         if  AroundCentre = 1 then do
  186.             adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement
  187.             call rotator(adjustment)
  188.             end
  189.  
  190.         if upper(linking)="Y" then linked = ppm_LinkBox(box,newbox)
  191.  
  192.         if scaling = 1 then do
  193.             ScaledWidth = ScaledWidth*abs(Xscale)
  194.             ScaledHeight = ScaledHeight*abs(Yscale)
  195.             ScaledImageX = ScaledImageX*Xscale
  196.             ScaledImageY = ScaledImageY*Yscale
  197.             call ppm_SetBoxSize(newbox,ScaledWidth,ScaledHeight)
  198.             call ppm_SetBoxScale(newbox,ScaledImageX,ScaledImageY)
  199.             vertical = vertical * abs(Yscale)
  200.             horizontal = horizontal * abs(Xscale)
  201.             end
  202.  
  203.         end   /* of column */
  204. end /* rows or columns = 1  */
  205.  
  206.  
  207. else do   /* for multiple columns  */
  208.  
  209. /* make first column */
  210. call ppm_ShowStatus("   Working on column 1")
  211.     do i = 2 to rows
  212.         k=i-1
  213.         box = boxes.1.k
  214.                 
  215.         /* to avoid a bug in